<?php

/**
* send_video.php
*
* Send file to browser 
*
* @author     Blazej Zieba <b@zieba.info>
* @copyright  2007 konekto.com
* @version    CVS: $Id:$
*/

require_once('MimeType.class.php');


if ( !isset($_GET['id']) || !strlen($_GET['id']) )
{
    trigger_error("send_video: Incorrect file name!", E_USER_ERROR);
    die();
} 

$fileName = basename( $_GET['id'] );

if (  !strlen($fileName) )
{
    trigger_error("send_video: Incorrect file name!", E_USER_ERROR);
    die();
}

$upload = &PEAR::getStaticProperty('CONFIG_INI','UPLOAD');
$mt = new MimeType();
header('Content-type: '.$mt->get($fileName));
header('Content-Disposition: attachment; filename="'.$fileName.'"');
header('Content-Length: ' . filesize($upload['upload_dir'].$fileName));

if ( !readfile($upload['upload_dir'].$fileName) )
{
    trigger_error("send_video: Incorrect file name!", E_USER_ERROR);
}
die();
?>
